package com.sanjiahantang.youjiarole.module.me.favorite.views.impl;

import android.support.annotation.IdRes;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.sanjiahantang.youjiarole.R;
import com.sanjiahantang.youjiarole.base.BaseMvpActivity;
import com.sanjiahantang.youjiarole.module.me.favorite.presenters.FavoritePresenter;
import com.sanjiahantang.youjiarole.module.me.favorite.views.FavoriteView;

/**
 * Created by zy on 2017/9/5.
 * 我的收藏
 */

public class FavoriteActivity extends BaseMvpActivity<FavoriteView,FavoritePresenter>
        implements FavoriteView,RadioGroup.OnCheckedChangeListener,View.OnClickListener {

    private RadioGroup rgTabs;
    private View back;
    @Override
    public void showProgress() {
        super.showProgress(this);
    }

    @Override
    public FavoritePresenter initPresenter() {
        return new FavoritePresenter();
    }

    @Override
    public void initView() {
        setContentView(R.layout.activity_favorite);
        rgTabs = (RadioGroup) findViewById(R.id.rgTabs);
        rgTabs.setOnCheckedChangeListener(this);
        presenter.initFragment(TAG_GOODS);
        back = findViewById(R.id.fl_Left);

        findViewById(R.id.rbCase).setTag(TAG_CASE);
        findViewById(R.id.rbGoods).setTag(TAG_GOODS);
        back.setOnClickListener(this);
    }

    @Override
    public void initData() {

    }

    @Override
    public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
        RadioButton rb = (RadioButton) rgTabs.findViewById(checkedId);
        presenter.changeFragment(rb.getTag().toString());
    }

    @Override
    public FragmentManager getMyFragmentManager() {
        return getSupportFragmentManager();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.fl_Left:
                finish();
                break;
        }
    }

    @Override
    public void onBackPressed() {
        finish();
    }
}
